from Calc import Calc
from unittest import TestCase
from ddt import ddt,data,unpack


@ddt
class TestCalc(TestCase):
    file = r"D:\Users\北极星的眼泪\Desktop\demo\单元测试第二天\计算器.xls"
    da = Calc()
    Add = da.get_data(file, 0)
    Minus = da.get_data(file, 1)
    Multi = da.get_data(file, 2)
    Ddevision = da.get_data(file, 3)

    @data(*Add)
    @unpack
    def testAdd1(self, a, b, c):
        ca = Calc()
        s = ca.add(a, b)

        self.assertEqual(s, c)


    @data(*Minus)
    @unpack
    def testMinus1(self, a, b, c):
        ca = Calc()
        s = ca.minus(a, b)

        self.assertEqual(s, c)

    @data(*Multi)
    @unpack
    def testMulti1(self, a, b, c):
        ca = Calc()
        s = ca.multi(a, b)

        self.assertEqual(s, c)

    @data(*Ddevision)
    @unpack
    def testDdevision1(self, a, b, c):
        ca = Calc()
        if b == 0:
            self.assertTrue(b)
        s = ca.devision(a, b)
        self.assertEqual(s, c)